package com.xkdx.guangguang.fragment.blog;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;
import com.xkdx.guangguang.shareclass.WeiBoDetail;
import com.xkdx.guangguang.shareclass.WeiboShop;

public class SinaBlogModule extends AbsModule {
	WeiboShop weiboShop;
	@Override
	public void parseData() throws Exception {
		backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("WeiboPage")) {
					weiboShop = parseWeiBo(jsonObj.getJSONObject("Content"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private WeiboShop parseWeiBo(JSONObject weibo) throws Exception{
		WeiBoDetail weiboDetail = new WeiBoDetail();
		WeiboShop weiboShop = new WeiboShop();
		try {
			JSONObject result = (JSONObject) weibo.get("Result");
			JSONObject detail = result.getJSONObject("DetailInfo");
			weiboDetail.setAccessToken(detail.getString("AccessToken"));
			weiboDetail.setShopWeibo(detail.getString("ShopWeibo"));
			weiboShop.setErrorCode(result.getString("ErrorCode"));
			weiboShop.setMessage(result.getString("Message"));
			weiboShop.setType(result.getString("Type"));
			weiboShop.setStatus(result.getString("Status"));
			weiboShop.setDetailInfo(weiboDetail);
		} catch (JSONException e) {
			e.printStackTrace();
			throw e;
		}
		return weiboShop;
	}

	

	
}
